package org.activequant.data.retrieval.mappings;

import org.activequant.core.domainmodel.InstrumentSpecification;
import org.activequant.core.domainmodel.data.TradeIndication;
import org.activequant.core.mappings.IInstrumentSpecificationMapper;
import org.activequant.core.types.TimeFrame;
import org.activequant.data.retrieval.ISubscription;
import org.activequant.data.retrieval.ITradeIndicationSubscriptionSource;

/**
 * TradeIndicationSubscriptionSourceMappingProxy extends SubscriptionSourceMappingProxy&lt;TradeIndication&gt; implements ITradeIndicationSubscriptionSource.
 * Holds the following associated variable:
 * <ul>
 * <li>source(ITradeIndicationSubscriptionSource)</li>
 * </ul>
 * Inherits the following variables:
 * <ul>
 * <li>subscriptions(List&lt;ISubscription&lt;TradeIndication&gt;&gt;)</li>
 * <li>mapper(IInstrumentSpecificationMapper)</li>
 * </ul>
 * <br>
 * <b>History:</b><br>
 *  - [20.01.2008] Created (Erik Nijkamp)<br>
 *
 *  @author Erik Nijkamp
 */
public class TradeIndicationSubscriptionSourceMappingProxy extends SubscriptionSourceMappingProxy<TradeIndication> implements ITradeIndicationSubscriptionSource {
	/**
	 * private ITradeIndicationSubscriptionSource source;
	 */
	private ITradeIndicationSubscriptionSource source;
	/**
	 * constructs a TradeIndicationSubscriptionSourceMappingProxy(extends SubscriptionSourceMappingProxy&lt;TradeIndication&gt; implements ITradeIndicationSubscriptionSource) 
	 * using the given source(ITradeIndicationSubscriptionSource) and mapper(IInstrumentSpecificationMapper) to set its associated
	 * source(ITradeIndicationSubscriptionSource) and inherited mapper(IInstrumentSpecificationMapper)
	 * @param source
	 * @param mapper
	 */
	public TradeIndicationSubscriptionSourceMappingProxy(ITradeIndicationSubscriptionSource source, IInstrumentSpecificationMapper mapper) {
		super(mapper);
		this.source = source;
	}
	/**
	 * subscribes and returns an ISubscription&lt;TradeIndication&gt; for the given spec(InstrumentSpecification) and timeFrame(TimeFrame) by using the associated 
	 * source(ITradeIndicationSubscriptionSource)
	 */
	protected ISubscription<TradeIndication> handleSubscribe(InstrumentSpecification spec, TimeFrame timeFrame) throws Exception {
		return source.subscribe(spec);
	}
}
